Skip to content

feat(auth): add progressive authentication prompts (Phase 2)#267

Merged
rosscado merged 9 commits intomainfrom
feat/auth-flow-phase2-prompts
Dec 31, 2025
Merged

feat(auth): add progressive authentication prompts (Phase 2)#267
rosscado merged 9 commits intomainfrom
feat/auth-flow-phase2-prompts

Conversation

@rosscado
Copy link
Copy Markdown
Contributor

@rosscado rosscado commented Dec 31, 2025

Summary

Implements progressive authentication prompts to gently encourage anonymous users to sign in based on their usage patterns. This is Phase 2 of the auth flow revamp initiative.

New Components

Component Purpose
UsageTracker Tracks interaction count (conversation turns + dictation completions), first use date, and prompt interactions in browser.storage.local
AuthPromptController Decides when/what prompts to show based on configurable thresholds
AuthPromptUI Toast and modal UI components with sign-in buttons

Progressive Thresholds

  • 5 interactions → Toast notification (non-blocking, auto-dismisses after 20s)
  • 10 interactions → Soft modal (dismissible overlay)
  • 20 interactions → Full modal with value proposition

Note: Interactions = conversation turns with chatbot + dictation completions (not raw transcription requests)

Toast
saypi signin 01 toast good

Soft Modal
saypi signin 02 soft modal

Hard Modal
saypi signin 03 hard modal

Smart Cooldowns

  • Base 5-minute cooldown between prompts
  • Exponential backoff after dismissals (doubles each time: 5min → 10min → 20min...)
  • Caps at 24-hour max cooldown
  • Stops showing prompts after 5 dismissals

User Experience

  • No prompts for already authenticated users
  • Hides prompts immediately when user signs in
  • Sign-in button opens extension settings page (reuses existing window if open)
  • "Maybe Later" dismissal option

Branding & Messaging

  • SayPi "Pi" logo in prompts (white bubble with black Pi on green background)
  • "SAY, PI" brand header to distinguish from host sites (Claude, Pi AI, etc.)
  • Value proposition reflects actual features:
    • Higher usage limits with free account
    • Text-to-speech voices (paid plans)
    • Premium features & chatbot support

Styling

  • Dark mode support
  • Mobile responsive design
  • Accessibility features (ARIA labels, focus trapping, reduced motion support)
  • Smooth animations
  • Toast positioned above VAD status indicator

Additional Fixes

  • Settings window reuse: clicking settings button focuses existing window instead of opening duplicates
  • Debug helper: saypiResetAuthPrompts() available in console for testing

Files Changed

New files:

  • src/auth/UsageTracker.ts - Usage tracking singleton
  • src/auth/AuthPromptController.ts - Prompt timing logic
  • src/auth/AuthPromptUI.ts - Toast and modal components
  • src/styles/auth-prompt.scss - Prompt styling
  • test/auth/UsageTracker.spec.ts - 5 tests
  • test/auth/AuthPromptController.spec.ts - 15 tests

Modified files:

  • src/saypi.index.js - Initialize auth prompt system, expose debug helper
  • src/svc/background.ts - Reuse existing settings window
  • _locales/en/messages.json - 8 new i18n messages

Test plan

  • All 655 tests pass (20 new tests added)
  • Build succeeds
  • Toast appears at 5 interactions with SayPi logo
  • Toast auto-dismisses after 20 seconds
  • Sign In and X buttons don't overlap
  • Soft modal appears at 10 interactions
  • Full modal appears at 20 interactions
  • Sign in hides prompts and opens settings
  • Settings window reused when already open
  • Verify dark mode styling
  • Verify mobile responsive layout

🤖 Generated with Claude Code

rosscado and others added 9 commits December 31, 2025 11:37
Implements progressive prompts to encourage anonymous users to sign in,
based on their usage patterns. Part of the auth flow revamp initiative.

Key features:
- UsageTracker: Tracks transcription count and prompt interactions
- AuthPromptController: Determines when to show prompts based on thresholds
  - Toast at 5 transcriptions
  - Soft modal at 10 transcriptions
  - Full modal with value proposition at 20 transcriptions
- AuthPromptUI: Toast and modal components with sign-in buttons
- Exponential backoff after dismissals (5min base, caps at 24h)
- Stops prompting after 5 dismissals
- Respects authentication state (no prompts for signed-in users)

UI features:
- Dark mode support
- Mobile responsive
- Accessibility (ARIA labels, focus trapping, reduced motion)
- Smooth animations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The auth toast was overlapping with the VAD status indicator since both
were positioned in the bottom-right corner. Move the toast up to
bottom: 100px to stack it above the VAD indicator (at bottom: 20px).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace anonymous user icon with SayPi bubble logo for brand recognition
- Add "Say, Pi" branding header to distinguish from host sites
- Track conversation turns/dictation completions instead of transcription
  requests (fixes prompts appearing too soon)
- Update benefit messages to reflect actual features:
  - Higher usage limits with free account
  - Text-to-speech voices (paid plans)
  - Premium features & chatbot support
- Add migration logic for existing usage stats

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When clicking the SayPi settings button multiple times, the extension
was opening a new popup window each time. Now it checks for an existing
settings window/tab and focuses it instead of creating duplicates.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Exposes window.saypiResetAuthPrompts() for testing auth prompts.
Run in console, then reload page to start fresh.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removed CSS filter that was making the entire SVG white, which hid
the "Pi" character. Now shows white bubble with black "Pi" on green
background - the proper SayPi branding.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added padding-right to content container to ensure space for the
absolutely-positioned close button, preventing overlap with the
Sign In button.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
10 seconds wasn't enough time to read the toast message.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rosscado rosscado merged commit bbe10fb into main Dec 31, 2025
1 check passed
@rosscado rosscado deleted the feat/auth-flow-phase2-prompts branch December 31, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant